package com.lock;

import org.openjdk.jol.info.ClassLayout;

/**
 * @author: csh
 * @Date: 2021/5/11 17:34
 * @Description:重量级锁
 */
public class WeightLock {
    static WeightLock weightLock = new WeightLock();
    public static void main(String[] args) throws InterruptedException {
        Thread.sleep(1000);
        new Thread(()->{
            synchronized (weightLock) {
                try {
                    weightLock.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(ClassLayout.parseInstance(weightLock).toPrintable());
            }
        }).start();
        Thread.sleep(5000);
        synchronized (weightLock){
            weightLock.notifyAll();
        }
    }
}
